Scripting PageInspector


The reader is assumed to have a basic knowledge of AppleScript.

PageInspector provides support for AppleScript. You will need Apple's Script Editor and AppleScript.
In Script Editor, choose "Open Dictionary..." from the "File" menu to see PageInspector's dictionary. A brief overview is given below:

Required Suite
Term Description
Open Opens a file.
Direct parameter Specifies the file to open.
readonly Takes three values: yes, no, and default.
"yes" will open the file read only
"no" will open the file giving PageInspector write access
"default" will open the file read only if you have "Open file as read only by default" set in the PageInspector preferences.
Print Currently does the same as open.
Direct parameter Specifies the file to open.
Quit Quits PageInspector.
saving Takes three values: yes, no, and ask. "yes" will save the open file on quit, "no" will discard any changes you made to the open file in PageInspector. "ask" will display the save changes dialog.
Run Opens PageInspector. This is done automatically in AppleScript through the "tell" statement.


Standard Suite
Term Description
Close Closes either a window or a document.
Direct parameter Specifies the document or window to close.
saving This parameter is identical to the "saving" parameter of the "Quit" term.
Count Returns the number of elements in a particular class. PageInspector allows you to get the count of the number of documents open, the number of errors in the Errors window, and the number of windows (including closed windows) open.
Direct parameter Specifies the object whose elements are to be counted.
Delete Allows you to delete the "cause" of an error from an HTML file.
Direct parameter Specifies the error to delete. The text that is underlined in the Error Preview bar when this error is highlighted will be deleted. The error will also be removed from the Error list.
Exists Returns a value of true if the object passes as the direct parameter exists. Otherwise, a value of false is returned.
Direct parameter Specifies the object in question.
Save Allows you to save any changes you have made to the open document.
Direct parameter Specifies the document to save.
Classes
Class Description
Window There are usually two elements in this class - one for the Information window, and one for the Error window. If no errors are found, and so the error window is not displayed, then the Window class will only contain one element - that of the Information window. You may access the windows contained in this class either by index, or by window name. The front window may be accessed by using an index of 1, the back window, or a closed window may be accessed by using an index of 2. You may also access a window by using the name that appears in the window's title bar, eg. "Errors" for the Error window, and "<file name> Info" for the Info window. Alternatively, to access the Info window, you may use the constant name "Info Wind".
bounds A rectangle that contains the boundary rectangle of the window. To change the size and position of a window, you can set this value.
closeable If this has a value of true, then the window in question has a close box, otherwise the window doesn't have a close box. You are unable to change the value of this property.
titled If this has a value of true, then the window in question has a title bar. You are unable to change the value of this property.
index This property contains the index of the window you are accessing. This is only useful if you access the window via it's name instead of it's index. Setting this value to 1 will bring a window of index 2 to the front. Setting this value to 2 will send a window of index 1 to the back. You can only change the value of this property if both windows are open.
floating If this property has a value of true, the window in question is a floating palette. Currently, there are no floating palettes in PageInspector. You are unable to set the value of this property.
modal If this property has a value of true, the window in question is a modal dialog. Currently, there are no modal dialogs in PageInspector. You are unable to set the value of this property.
resizable If this property has a value of true, the window in question can be resized, that is, there is a size box in the lower right hand corner of the window. You are unable to set the value of this property.
zoomable If this property has a value of true, the window in question has a zoom box. Currently, none of PageInspector's windows have a zoom box, though this should change by next version. You are unable to set the value of this property.
zoomed If this property has a value of true, the window in question is zoomed to full size. As no windows in PageInspector are zoomable at the moment, this property is currently useless.
name This property contains the text that is shown in the title bar of the window in question. You are unable to set the value of this property.
visible If this property has a value of true, then the window is currently on screen, although it may not necessarily be the front window. If you set the value of this property to false, the window in question is closed. If there are no other windows open, the open file is closed as well, and if any changes have been made to the file, the save changes dialog will be displayed.
position This property contains the top left co-ordinates of the window in question. Setting this value will move the window, without bringing it to the front or changing its dimensions.


PageInspector Suite
Term Description
Scanning File Allows you to find out if PageInspector is currently scanning a file. A value of true will be returned if a file is being scanned, otherwise a value of false will be returned. If you try to access properties of classes or send an event to PageInspector while a scan is taking place, you will receive an error.
Classes
Class Description
Document In this version of PageInspector, there is a maximum of one element in this class at a time, as you cannot have multiple files open. You can access the one element either by its index (1), or by the file's name.
the file This property contains a file specification of the open file. You can use this property to open the file in other programs, or to access the file in the Finder. You are unable to set the value of this property.
index The index of the document in question. You are unable to set the value of this property.
title The internal title of the HTML document. You can use "exists title of document 1" if unsure of whether the open document has a title. You are unable to set the value of this property.
modified This boolean value is set to true if the document has been modified within PageInspector since being opened. You are unable to change the value of this property, but it you wish to save modifications made to a file, use the save command.
read only If the value of this property is true, then the document was opened read only, and cannot be modified from within PageInspector. You are unable to modify the value of this property
path The path of the specified document, as it appears in the Info Window, is stored in this value. You are unable to modify the value of this property.
download This property contains the number of seconds the specified document will take to download, including the time to download all linked images, etc., although the time to download any images on a frame source is not included in this estimate. A value of 0 means that the specified document will take less than a second to download. You are unable to modify the value of this property.
has frames If the value of this property is true, the specified document contained frames. This information may be useful if you want to know if the value obtained from "download of document 1" is correct. (See above.)
links checked if this property contains a value of true, the links of the specified document were checked. If the value of this property is false, links were not checked, and so the download time of the document will not include any linked images, etc.
HTML Error This class contains information about all errors in the Error window. You can access an error only via its index and you can obtain the number of errors found in a file through "get count of HTML Error".
error string This is the actual string that is shown in the error window. You are unable to set the value of this property.
type This property contains the type of the specified error, as indicated by the icon that appears next to the error in the Error list. This property will contain the value either:
  • "Error" - The error has the stop icon
  • "Warning" - The error has the caution icon
  • "Link Error" - The error has the "Link" icon
  • "Note" - The error has the "speech bubble" icon
  • "'PageMill' Error" - The error is telling you that you have a non-standard HTML tag or attribute in the file that has been inserted by Adobe PageMill/SiteMill.
  • "'HomePage' Error" - The error is telling you that you have a non-standard HTML tag or attribute in the file that has been inserted by Claris Home Page.
fixable This boolean value is set to true if the specified error can be fixed automatically by PageInspector via the "Fix" button. You cannot set the value of this property.
deleteable This boolean value is set to true if the specified error can be deleted by PageInspector via the "Trash" button. You cannot set the value of this property.
explanation This property contains the string that is displayed under the heading "Explanation" in the "Error Information" dialog. You cannot set the value of this property.
solution This property contains the string that is displayed under the heading "Solution" in the "Error Information" dialog. You cannot set the value of this property.
start position This property contains the character index of the first character that appears underlined in the Error preview bar. You can use this value to locate the specified error's position in other applications. You cannot set the value of this property.
end position This property contains the character index of the last character that appears underlined in the Error preview bar. You can use this value to locate the specified error's position in other applications. You cannot set the value of this property.
position known This property contains a value of true if the position of the specified error is known to PageInspector (ie. If text appears in the Error Preview bar when the specified error is highlighted.). You cannot set the value of this property.
cause This property contains the text that is underlined when the specified error is highlighted. You cannot set the value of this property.



Return to the Contents Page